﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using OttawaTourMap.Resources.Localization;

namespace OttawaTourMap
{
    public partial class ToursListPage : PhoneApplicationPage
    {
       public ToursListPage()
		{
			InitializeComponent();
            LocalizeStrings();
		}

       private void LocalizeStrings()
       {
           ApplicationTitle.Text = Labels.Tour_List;
       }

		private void ListBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
		{
			//Do nothing if there is no selection
			if(toursListBox.SelectedIndex == -1)
				return;

            //Get the ID of the tour
            System.Windows.Controls.ListBox tourListBox = sender as ListBox;
            Expression.Blend.SampleData.ottawaSampleDataSource.tour selectedTour = tourListBox.SelectedItem as Expression.Blend.SampleData.ottawaSampleDataSource.tour;

            string id = selectedTour.id;

			//Navigate to details page and inform the selection
            NavigationService.Navigate(new Uri("/TourDetailsPanoramicView.xaml?tourIndex=" + id, UriKind.Relative));
			//Reset to no selection
			toursListBox.SelectedIndex = -1;
		}

        private void thumbNailImage_Loaded(object sender, RoutedEventArgs e)
        {
            var img = (Image)sender;
           
        }

        private void ContentPanel_Loaded(object sender, RoutedEventArgs e)
        {
            
            TourInfoList.AnimateTiles(VirtualDreams.Turnstile.EnterMode.Enter, VirtualDreams.Turnstile.YDirection.TopToBottom, VirtualDreams.Turnstile.ZDirection.BackToFront);
        }

       
    }
}